#!/usr/bin/python
#coding:utf8

"""
Command
"""
# 接收者
class Bulb:
    def turnOn(self):
        print("Bulb has been lit")

    def turnOff(self):
        print("Darkness!")


# 命令
class Command:
    def execute(self):
        pass
    def undo(self):
        pass
    def redo(self):
        pass

class TurnOn(Command):
    def __init__(self, bulb):
        self.bulb = bulb
    def execute(self):
        self.bulb.turnOn()
    def undo(self):
        self.bulb.turnOff()
    def redo(self):
        self.bulb.turnOn()

class TurnOff(Command):
    def __init__(self, bulb):
        self.bulb = bulb
    def execute(self):
        self.bulb.turnOff()
    def undo(self):
        self.bulb.turnOn()
    def redo(self):
        self.bulb.turnOff()

# 调用者
class RemoteControl:
    def submit(self, command):
        command.execute()



if __name__ == "__main__":
    bulb = Bulb()
    turnon = TurnOn(bulb)
    turnoff = TurnOff(bulb)
    remote = RemoteControl()
    remote.submit(turnon)
    remote.submit(turnoff)